package com.woodws.fresh.im.controller

import com.woodws.fresh.common.core.extra.log
import com.woodws.fresh.im.api.dto.ImSessionDto
import com.woodws.fresh.im.api.service.ImSessionService
import com.woodws.fresh.im.rsocket.ServerClient
import com.woodws.fresh.im.rsocket.UserClient
import org.springframework.messaging.handler.annotation.MessageMapping
import org.springframework.messaging.handler.annotation.Payload
import org.springframework.messaging.rsocket.RSocketRequester
import org.springframework.messaging.rsocket.annotation.ConnectMapping
import org.springframework.stereotype.Controller

@Controller
class ConnectController(val userClient: UserClient,
                        val serverClient: ServerClient
) {

    companion object{
        val CLIENTS: MutableMap<String, RSocketRequester> = mutableMapOf()
    }


    @ConnectMapping
    fun connect(requester: RSocketRequester, @Payload session: ImSessionDto){
        userClient.login(requester, session)
    }

}